import { useEffect, useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);
  useEffect(() => {
    // 组件挂载或更新时执行
    document.title = `Count: ${count}`;

    // 清理函数（组件卸载时执行）
    return () => {};
  }, [count]);
  function Increment() {
    setCount(count + 1);
    console.log(count);
  }

  return (
    <div>
      Count: {count}
      <button onClick={Increment}>Increment</button>
    </div>
  );
}

export default function HookDS() {
  return (
    <>
      <Counter />
    </>
  );
}
